package com.ews.onlineexchange.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.enterprise.inject.Model;

import com.ews.onlineexchange.model.Category;

@Model
public class CategoryList extends EntityQuery<Category> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Map<String, Category> nameMap = new HashMap<String, Category>();

	public Map<String, Category> getNameMap() {
		if (nameMap.isEmpty()) {
			List<Category> resultList = getResultList();
			for (Category category : resultList) {
				nameMap.put(category.getName(), category);
			}
		}
		return nameMap;
	}

	public String getPort() {
		return System.getProperty("webServicePort");
	}

}
